package view.mwgde;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComboBox;
import javax.swing.JLabel;

import model.mwgde.IMWGDEInterface;
import view.CenterTabbedPane.EBenchmarkTab;
import view.parameterpanels.StandardParameterInputPanel;

/**
 * The view class {@code MaterialPanelMWGDE} is used for material parameters
 * of type 'machining with geometrically defined edges'. Besides the parameter
 * manipulation the user can choose between different material types that are
 * used during the process. The settingsPanel is used for this.
 * @author Oliver Eckstein
 *
 */
public class MaterialPanelMWGDE extends StandardParameterInputPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;	
	
	/**
	 * To create a new {@code GeometryPanelMWGDE}.
	 * @param logoPath a path to an optional logo. If passed {@code null} a
	 * standard logo is used.
	 * @param tab the type of input parameters that is displayed on the panel.
	 * @param panelTitle the panel's title.
	 * @param manuMethod the model to be referenced.
	 */
	public MaterialPanelMWGDE(
			String logoPath,
			EBenchmarkTab tab,
			String panelTitle,			
			IMWGDEInterface manuMethod) {
		super(logoPath, tab, panelTitle, manuMethod);		
	}

	@Override
	protected void drawSettings() {
		final IMWGDEInterface mwgde = (IMWGDEInterface) manuMethod;
        final JComboBox<String> cb = 
        		new JComboBox<String>(mwgde.getMaterials());
        cb.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				if(e.getSource() == cb) {
		            String material = (String) cb.getSelectedItem();
		            mwgde.setMaterial(mwgde.stringToMaterial(material));
		        }
			}
        	
        });
        settings.add(new JLabel("Materialtyp"));        
    	settings.add(cb);		
	}

}
